<template>
	<view v-if="pageShow">
		<logistics :wlInfo="wlInfo"></logistics>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	import logistics from '@/components/xinyu-logistics/xinyu-logistics.vue'
	export default {
		components: {
			logistics
		},
		data() {
			return {
				listid: "",
				wlInfo: {},
				addr:"",
				pageShow:false
			}
		},
		onLoad(options) {
			this.listid = options.id
			this.addr = options.addr
			this.getDetail()
		},
		methods: {
			getDetail() {
				uni.showLoading({
					mask:true,
					title:"请稍后"
				})
				httpRequest.request('/api/ordercl/lookWlInfo', 'GET', {
					express_no: this.listid,
				}).then(res => {
					uni.hideLoading()
					if(res.code==1){
						let data = res.data[0]
						let wlInfo = {
							delivery_status:data.logisticsStatus=="SIGN"?1:2,
							post_name:data.logisticsCompanyName,//快递公司
							post_no:data.mailNo,//快递单号
							addr:this.addr,//收货地址
							list:[]
						}
						data.logisticsTraceDetailList.forEach(item=>{
							wlInfo.list.unshift({
								"timeArr": this.timereturn(item.time),
								"context": item.desc,
								"location": item.areaName
							})
						})
						this.wlInfo = wlInfo
						this.pageShow = true
					}else{
						httpRequest.toast(res.msg)
						setTimeout(()=>{
							uni.navigateBack(1)
						},1000)
					}
					
				})
			},
			timereturn(time3){
				      //将时间戳格式转换成年月日时分秒
				      var date = new Date(time3);
				      var Y = date.getFullYear() + '-';
				      var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
				      var D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()) + ' ';
				
				      var h = (date.getHours() < 10 ? '0' + (date.getHours()) : date.getHours()) + ':';
				      var m = (date.getMinutes() < 10 ? '0' + (date.getMinutes()) : date.getMinutes()) + ':';
				      var s = (date.getSeconds() < 10 ? '0' + (date.getSeconds()) : date.getSeconds());
				      var strDate = [Y + M + D,h + m + s];
					  return strDate
			
			},
			
		}
	}
</script>

<style>

</style>